<?php
	require_once("../conexion/conexion.php");

	extract($_POST);
	$nc = $_GET['nc'];
	
	$con = new Conexion();
	$con2 = $con->conexionBD("fpproduccion");
	$sql = "select
				date_format(NotCreFecha,'%d-%m-%Y') as fecha,
				NotCreRut,
				NotCreRSocial,
				NotCreDir,
				NotCreCiu,
				NotCreCom,
				NotCreGiro,
				NotCreFPago,
				NotCreNeto
				
				from notacredito
				where NotCreNum='".$nc."'";
	$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$datos = mysql_fetch_array($res);
	
	$nombre = utf8_decode($datos[2]);
	$dir = utf8_decode($datos[3]);
	$giro = utf8_decode($datos[6]);
	$comuna = utf8_decode($datos[5]);
	$ciudad = utf8_decode($datos[4]);
	
	//busca detalle
	$con = new Conexion();
	$con2 = $con->conexionBD("fpproduccion");
	$sql = "select
				DetCant,
				DetObs,
				DetUnit,
				DetTotal
				
				from detallenotcre
				where NotCreNum='".$nc."'";
	$res2 = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nota Credito - <?php echo $nc;?></title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<script src="../include_js/jquery.js" type="text/javascript"></script>
<script src="../include_js/popcalendar.js" type="text/javascript"></script>
<style>
.texto
{
	font-size:14px;
	margin-left:8px;
	font:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
}
.borde
{
	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.bordeA {	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.datos
{
	font-size:12px;
	font:Verdana; 
	color:#333333;
}
</style>
</head>

<body>
<a name="arriba"></a>
<br class="end" />
<div id="area">
 <div id="navbar">
    	<div class="righty"></div>
        <div class="lefty"></div>
		<ul>
            <li><label style="font-size:12px;">Nota Credito N&deg; "<?php echo $nc;?>"</label></li>
		</ul>
 </div>
 <div id="content">
<form name="form_exp" id="form_exp" method="post">
<table width="100%" cellpadding="2" cellspacing="0" border="0" class="uno">
<tr>
  <td width="12%" class="borde">&nbsp;</td>
  <td width="56%" class="borde">&nbsp;</td>
  <td width="11%" class="borde">&nbsp;</td>
  <td width="21%" class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Fecha:</label></td>
  <td class="borde"><label class="datos"><?php echo $datos[0]?></label></td>
  <td class="borde" style="text-align:right">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Se&ntilde;or:</label></td>
  <td class="borde"><label class="datos"><?php echo $nombre;?></label></td>
  <td class="borde" style="text-align:right"><label class="texto">Rut:</label></td>
  <td class="borde"><label class="datos"><?php echo $datos[1]?></label></td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Direcci&oacute;n:</label></td>
  <td class="borde"><label class="datos"><?php echo $dir;?></label></td>
  <td class="borde" style="text-align:right"><label class="texto">Ciudad:</label></td>
  <td class="borde"><label class="datos"><?php echo $ciudad;?></label></td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Giro:</label></td>
  <td class="borde"><label class="datos"><?php echo $giro;?></label></td>
  <td class="borde" style="text-align:right"><label class="texto">Comuna:</label></td>
  <td class="borde"><label class="datos"><?php echo $comuna;?></label></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;">&nbsp;</td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde" colspan="4"><div style="margin-left:10px;">
  <table border="0" cellpadding="2" cellspacing="0" width="95%">
  <thead>
  <tr>
  	<th width="10%">cant.</th>
  	<th width="50%">detalle</th>
	<th width="21%">p. unitario</th>
	<th width="19%">total</th>
  </tr>
  </thead>
  <?php
  	$suma = 0;
  	while ($row = mysql_fetch_row($res2))
	{
		$suma+=$row[3];
		echo "<tr class='filaImpar'>";
		echo "<td style='text-align:center;'>".$row[0]."</td>";
		echo "<td>".$row[1]."</td>";
		echo "<td style='text-align:right;padding-right:40px;'>".number_format($row[2],0,',','.')."</td>";
		echo "<td style='text-align:right;padding-right:40px;'>".number_format($row[3],0,',','.')."</td>";
		echo "</tr>";
	}
	$iva = round($suma*0.19);
	$total = $suma+$iva;
  ?>
  <tr bgcolor="#CCCCCC">
  	<td colspan="3" style="text-align:right; padding-right:10px;">NETO:</td>
	<td style='text-align:right;padding-right:40px;'><?php echo number_format($suma,0,',','.');?></td>
  </tr>
  <tr bgcolor="#CCCCCC">
  	<td colspan="3" style="text-align:right; padding-right:10px;">IVA:</td>
	<td style='text-align:right;padding-right:40px;'><?php echo number_format($iva,0,',','.');?></td>
  </tr>
   <tr bgcolor="#CCCCCC">
  	<td colspan="3" style="text-align:right; padding-right:10px;">TOTAL:</td>
	<td style='text-align:right;padding-right:40px;'><?php echo number_format($total,0,',','.');?></td>
  </tr>
  </table>
  </div>  </td>
</tr>
<tr>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
</table>
</form>
 </div>
 <div id="close">
    	<div class="righty"></div>
    	<div class="lefty"></div>
 </div>
</div>
</body>
</html>